1
/****************************** Module Header ******************************\
2 Module Name: NativeMethods.cs
3 Project: CSWebBrowserWithProxy
4 Copyright (c) Microsoft Corporation.
6 This class is a simple .NET wrapper of wininet.dll. It contains 4 extern
7 methods in wininet.dll. They are InternetOpen, InternetCloseHandle,
8 InternetSetOption and InternetQueryOption.
10 This source is subject to the Microsoft Public License.
11 See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 All other rights reserved.
14 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
15 EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
17 \***************************************************************************/
20 using System
.Runtime
.InteropServices
;
22 namespace CSWebBrowserWithProxy
24 internal static class NativeMethods
27 /// Initialize an application's use of the WinINet functions.
30 [DllImport("wininet.dll", SetLastError
= true, CharSet
= CharSet
.Auto
)]
31 internal static extern IntPtr
InternetOpen(
35 string lpszProxyBypass
,
39 /// Close a single Internet handle.
41 [DllImport("wininet.dll", SetLastError
= true)]
42 [return: MarshalAs(UnmanagedType
.Bool
)]
43 internal static extern bool InternetCloseHandle(IntPtr hInternet
);
46 /// Sets an Internet option.
48 [DllImport("wininet.dll", CharSet
= CharSet
.Ansi
, SetLastError
= true)]
49 internal static extern bool InternetSetOption(
51 INTERNET_OPTION dwOption
,
53 int lpdwBufferLength
);
56 /// Queries an Internet option on the specified handle. The Handle will be always 0.
58 [DllImport("wininet.dll", CharSet
= CharSet
.Ansi
, SetLastError
= true)]
59 internal extern static bool InternetQueryOption(
61 INTERNET_OPTION dwOption
,
62 ref INTERNET_PER_CONN_OPTION_LIST OptionList
,
63 ref int lpdwBufferLength
);